package cn.cdeden.knowledge.controller.Individual;

//import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiOperation;
import cn.cdeden.common.core.domain.R;
import cn.cdeden.knowledge.domain.dto.EnterpriseConfigDto;
import cn.cdeden.knowledge.service.EnterpriseConfigService;
import cn.cdeden.knowledge.utils.EnterpriseConfigUtils;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
* @author GW
* @date 2024-08-06
**/
@RestController
@RequiredArgsConstructor
//@Api(tags = "企业配置管理")
@RequestMapping("/api/enterpriseConfig")
public class EnterpriseConfigController {

    private final EnterpriseConfigService enterpriseConfigService;

    private final EnterpriseConfigUtils enterpriseConfigUtils;
    @GetMapping
//    @Log("查询企业配置")
//    @ApiOperation("查询企业配置")
    public R<List<EnterpriseConfigDto>> query(){
        List<EnterpriseConfigDto> info = enterpriseConfigUtils.getEnterpriseConfigInfos();
        return R.ok(info);
    }


    @PostMapping
//    @Log("设置企业配置")
//    @ApiOperation("设置企业配置")
    public R<EnterpriseConfigDto> update(@RequestBody List<EnterpriseConfigDto> enterpriseConfigDtos){
        enterpriseConfigService.updateByArray(enterpriseConfigDtos);
        return R.ok();
    }

    @GetMapping("/getInfoByCode")
//    @Log("查询企业配置通过code")
//    @ApiOperation("查询企业配置通过code")
    public R<EnterpriseConfigDto> getInfoByCode(@RequestParam String code){
        return R.ok(enterpriseConfigUtils.getEnterpriseConfigInfoByCode(code));
    }
    /*
//    @Log("导出企业配置")
//    @ApiOperation("导出企业配置")
    @GetMapping(value = "/download")
    @PreAuthorize("@el.check('enterpriseConfig:list')")
    public void download(HttpServletResponse response, EnterpriseConfigQueryParam query) throws IOException {
        enterpriseConfigService.download(enterpriseConfigService.queryAll(query), response);
    }*/

}
